/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.killgun.physics;

import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.objects.PhysicsCharacter;
import com.jme3.scene.Spatial;
import com.killgun.configuration.ConfigManager;
import java.util.Properties;

/**
 *
 * @author pandtonic
 */
public class PhysicsHelper {

    private PhysicsSpace physicsSpace;
    private static final Properties prop = ConfigManager.getInstance();
    public static final int JUMP_SPEED = Integer.parseInt(prop.getProperty(
            "phys.jump_speed"));
    public static final int FALL_SPEED = Integer.parseInt(prop.getProperty(
            "phys.fall_speed"));
    public static final int GRAVITY = Integer.parseInt(prop.getProperty(
            "phys.gravity"));

    public PhysicsHelper(PhysicsSpace physicsSpace) {
        this.physicsSpace = physicsSpace;
    }

    public RigidBodyControl addSolid(Spatial spatial) {
        RigidBodyControl rigidBodyControl = new RigidBodyControl(0);
        spatial.addControl(rigidBodyControl);
        physicsSpace.add(rigidBodyControl);
        return rigidBodyControl;
    }

    public PhysicsCharacter addPlayer(Spatial spatial) {
        PhysicsCharacter player = new PhysicsCharacter(
                new SphereCollisionShape(5), .01f);
        player.setJumpSpeed(JUMP_SPEED);
        player.setFallSpeed(FALL_SPEED);
        player.setGravity(GRAVITY);
        if (spatial != null) {
        }
        physicsSpace.add(player);
        return player;
    }
}
